﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
using GalaSoft.MvvmLight.Command;
using MishraReader.ViewModels.AppServices;

namespace MishraReader.ViewModels.Settings
{
    public class Developer
    {
        public static readonly Uri DefaultImage;
        private static readonly IUrlLauncher Launcher;

        static Developer()
        {
            DefaultImage = new Uri("pack://application:,,,/MishraReader;component/Assets/DeveloperDefaultImage.jpg");
            Launcher = ServiceLocator.Current.GetInstance<IUrlLauncher>();
        }

        public Developer()
        {
            DeveloperImage = DefaultImage;

            ShowSiteCommand = new RelayCommand(() => Launcher.LaunchUri(new Uri("http://" + Site)));
            SendMailCommand = new RelayCommand(() => Launcher.LaunchUri(new Uri("mailto:" + Mail)));
            ShowTwitterCommand = new RelayCommand(() => Launcher.LaunchUri(new Uri("http://twitter.com/#!/" + Twitter.Substring(1))));
        }

        public string Company { get; set; }

        public Uri DeveloperImage { get; private set; }

        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Mail { get; set; }

        public string Name
        {
            get { return string.Format("{0} {1}", FirstName, LastName.ToUpper()); }
        }

        public ICommand SendMailCommand { get; internal set; }
        public ICommand ShowSiteCommand { get; internal set; }
        public ICommand ShowTwitterCommand { get; internal set; }
        public string Site { get; set; }
        public string Twitter { get; set; }

        public static IEnumerable<Developer> All
        {
            get
            {
                return (new[]
                    {
                        new Developer
                            {
                                FirstName = "David",
                                LastName = "CATUHE",
                                Company = "Microsoft",
                                Site = "blogs.msdn.com/eternalcoding",
                                Mail = "davca@microsoft.com",
                                Twitter = "@deltakosh"
                            },
                        new Developer
                            {
                                FirstName = "Julien",
                                LastName = "CORIOLAND",
                                Company = "Infinite Square",
                                Site = "www.juliencorioland.net",
                                Mail = "contact@juliencorioland.net",
                                Twitter = "@beedoo"
                            },
                        new Developer
                            {
                                FirstName = "Christopher",
                                LastName = "MANEU",
                                Company = "Bewise",
                                Site = "www.maneu.net",
                                Mail = "christopher@maneu.net",
                                Twitter = "@cmaneu"
                            },
                        new Developer
                            {
                                FirstName = "Thomas",
                                LastName = "LEBRUN",
                                Company = "Infinite Square",
                                Site = "blogs.developpeur.org/tom",
                                Mail = "lebrun_thomas@hotmail.com",
                                Twitter = "@thomas_lebrun"
                            },
                        new Developer
                            {
                                FirstName = "Olivier",
                                LastName = "COURTOIS",
                                Company = "Bewise",
                                Site = "www.ocourtois.fr",
                                Mail = "olivier.courtois@bewise.fr",
                                Twitter = "@ocourtois"
                            },
                        new Developer
                            {
                                FirstName = "Jonathan",
                                LastName = "ANTOINE",
                                Company = "Infinite Square",
                                Site = "www.jonathanantoine.com",
                                Mail = "me@jonathanantoine.com.com",
                                Twitter = "@jmix90"
                            },
                        new Developer
                            {
                                FirstName = "Rudy",
                                LastName = "HUYN",
                                Company = "Orange Business Services",
                                Site = "www.rudyhuyn.com",
                                Mail = "contact@rudyhuyn.com",
                                Twitter = "@rudyhuyn"
                            },
                        new Developer
                            {
                                FirstName = "Cyril",
                                LastName = "SANSUS",
                                Company = "Bewise",
                                Site = "blogs.codes-sources.com/vko/",
                                Mail = "cyril.sansus@gmail.com",
                                Twitter = "@Vko31"
                            },
                        new Developer
                            {
                                FirstName = "Oren",
                                LastName = "NOVOTNY",
                                Company = "Microsoft",
                                Mail = "oren@novotny.org",
                                Twitter = "@onovotny"
                            },
                    }).OrderBy(d => d.LastName);
            }
        }
    }
}